-- Une plaque de pression
MSwitch = {}

function MSwitch:new(x, y, actions)
	local o = o or {}   -- create object if user does not provide one
	o.x = x or 0
	o.y = y or 0
	o.actions = actions or {}
	o.nb_pressed = 0
	o.released = true
	
	setmetatable(o, self)
	self.__index = self
	return o
end

function MSwitch:press()
	if self.released then
		for k_action, v_action in pairs(self.actions[(self.nb_pressed%(#self.actions))+1]) do 
			v_action:doAction()
		end
		self.nb_pressed = self.nb_pressed+1
		self.released = false
	end
end

function MSwitch:release() 
	self.released = true
end